package com.cctc.rds.nrpc.core.protocol.serializer;

import com.cctc.rds.nrpc.core.protocol.serializer.impl.JdkSerializer;
import com.cctc.rds.nrpc.core.protocol.serializer.impl.JsonSerializer;

public interface Serializer {

    static Serializer getSerializer(SerializerType type) {
        Serializer serializer = null;
        switch (type) {
            case JDK:
                serializer = new JdkSerializer();
                break;
            case JSON:
                serializer = new JsonSerializer();
                break;
            default:
                serializer = new JsonSerializer();
        }
        return serializer;
    }

    Byte getSerializerType();

    byte[] serialize(Object o);

    <T> T deserialize(Class<T> tClass, byte[] data);

}
